﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Ycm20250401.Service._20250410
{
    // 订单服务：管理订单状态
    public class OrderService20250410
    {
        public Order GetOrder(string orderId)
        {
            // 模拟从数据库获取订单
            return new Order
            {
                OrderId = orderId,
                Status = OrderStatus.Delivered, // 假设订单已签收
                TotalAmount = 500.00m,
                UserEmail = "user@example.com"
            };
        }

        public bool ValidateReturn(Order order)
        {
            // 验证订单是否满足退货条件
            return order.Status == OrderStatus.Delivered;
        }
    }

    // 库存服务：恢复库存
    public class InventoryService
    {
        public void RestockItems(List<string> productIds)
        {
            // 模拟库存恢复逻辑
            foreach (var productId in productIds)
            {
                Console.WriteLine($"已恢复商品 {productId} 的库存");
            }
        }
    }

    // 支付服务：处理退款
    public class PaymentService
    {
        public bool RefundPayment(Order order)
        {
            // 模拟调用支付网关退款
            Console.WriteLine($"已退款 {order.TotalAmount} 至用户账户");
            return true; // 假设退款成功
        }
    }

    // 通知服务：发送邮件/短信
    public class NotificationService
    {
        public void SendReturnConfirmation(string email, string orderId)
        {
            // 模拟发送通知
            Console.WriteLine($"已发送退货确认邮件至 {email}，订单号：{orderId}");
        }
    }

    // 订单状态枚举
    public enum OrderStatus { Pending, Shipped, Delivered, Cancelled }

    // 订单实体类
    public class Order
    {
        public required string OrderId { get; set; }
        public OrderStatus Status { get; set; }
        public decimal TotalAmount { get; set; }
        public required string UserEmail { get; set; }
        public List<string> ProductIds { get; set; } = new List<string> { "P1001", "P1002" };
    }

}
